<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>录单</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../../../css/reset.css" />
		<link href="../../../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../../../css/cmms.css" />
		<link rel="stylesheet" href="../../../../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../../../../css/iconfont.css?time=321" />
		<link rel="stylesheet" href="../../../../css/sale/single/single.css?time=321" />
		<script src="../../../../js/vconsole.min.js"></script>
	</head>
	<style type="text/css">
		/* #selectItems .inputBox>input{
			padding: 2px 3px;
			font-size: 14px;
		} */
		#selectItems .inputBox>.search {
		    font-size: 12px;
		    color: #dbdbdb;
				position: static;
		}
	</style>
	<body>
		<div class="mui-content" id="single" v-cloak>
			<div id="single1" v-show='show1'>
				<ul class="singleList">
					<li class="singleListItem1">
						<i class="icon iconfont icon-icon1 basic-color"></i>
						<div>
							<span class="doctor">{{doctor}} （ID {{userId}}）</span>
							<span class="clinic">{{hospital}}</span>
						</div>
					</li>
					<li class="singleListItem2" @tap="jumpToAdd">
						<i class="icon iconfont icon-ren basic-color"></i>
						<span class="title">{{subject}}</span>
						<i class="mui-icon mui-icon-arrowright right"></i>
					</li>
					<li class="singleListItem2" @tap="jumpSelectItem">
						<i class="icon iconfont icon-02 basic-color"></i>
						<span class="title">{{selectItem}}</span>
						<i class="mui-icon mui-icon-arrowright right"></i>
					</li>
					<li class="singleListItem4">
						<div>
							<i class="icon iconfont icon-tiaoma2 basic-color"></i>
							扫服务码
						</div>
						<div>
							<input type="text" placeholder="请扫描或输入服务码" v-model="inputCode" @change="addBarCode"/>
							<i class="icon iconfont icon-saomiao right" @tap="scanBarcode"></i>
						</div>
						<ul v-show="barCodeArr">
							<li >
								条码：{{barCodeArr}}
								<i class="icon iconfont icon-shanchu" @tap="delBarCode()"></i>
							</li>
						</ul>
					</li>
					<li class="singleListItem7">
						<div>
							<i class="icon iconfont icon-yixuemedicine17 basic-color"></i>
							医学样本
						</div>
						<div class="samplingBox">
							<span @tap="selectSample"><input type="text" placeholder="" v-model="selSample" readonly unselectable="on" /><i class="iconfont icon-jiantou"></i></span>
							<span @tap="selectNum"><input type="text" placeholder="" v-model="selNum" readonly unselectable="on" /><i class="iconfont icon-jiantou"></i></span>
							<span class="btn-detail" @tap="addSample">确认</span>
						</div>
						<ul>
							<li v-for="(specimenSampling,index) in specimenSamplingParams">
								<span>{{specimenSampling.samplingColor}}</span> <span>×{{specimenSampling.samplingNum}}</span>
								<i class="icon iconfont icon-shanchu" @tap="delSample(index)"></i>
							</li>
						</ul>
					</li>
					<li class="singleListItem5">
						<div>
							<i class="icon iconfont icon-iconfontpicfill basic-color"></i>
							申请单上传
						</div>
						<ul>
							<li v-for="src,index in imgSrcs" class="localImg">
								<i class="iconfont icon-jianqu" @tap="delwxIMG(index)"></i>
								<img :src="src" alt="申请单" @tap="getImg(src)"/>
							</li>
							<li @tap="uploadImg"><i class="icon iconfont icon-xiangji1"></i></li>
						</ul>
					</li>
					<li class="singleListItem6" @tap="selectSamplingTime">
						<i class="icon iconfont icon-shijian basic-color"></i>
						<span>采样时间</span>
						<span class="samplingTime">{{samplingTime|replaceT}}</span>
						<i class="icon iconfont icon-date right"></i>
					</li>
					<li class="singleListItem8" >
						<i class="icon iconfont icon-beizhu basic-color"></i>
						<span>备注</span>
						<div class="remarkBox">
        					<textarea class="content" placeholder="请输入内容" v-model="remark"></textarea>
						</div>
					</li>
				</ul>
				<div class="btnBox">
					<button class="submit-btn" :class="{'hidden':isSubmit}">提交订单</button>
					<button class="submit-btn" :class="{'hidden':!isSubmit}" @tap="submitOrder">提交订单</button>
				</div>
			</div>
			<div id="addPainter" v-show="show2">
				<ul class="messageList">
					<li class="listItem1">
						姓名
						<input type="text" v-model="patientName" placeholder="请输入姓名"/>
					</li>
					<li class="listItem2" @tap="selectSex">
						性别
						<input type="text" v-model="sexMsg"/>
						<i class="mui-icon mui-icon-arrowright"></i>
					</li>
					<li class="listItem3" >
						<span>年龄<input type="tel" v-model="dateBirth" placeholder="请输入年龄" /></span>
						<div class="selectBox" @tap="selectAgeUnit">
							<span>
								<input type="text" readonly unselectable="on" v-model="ageUnit" />
								<i class="iconfont icon-chakangengduo"></i>
							</span>
						</div>
					</li>
					<li class="listItem4">
						电话
						<input type="tel" v-model="patientPhone"/>
					</li>
				</ul>
				<div class="buttomBox">
					<button class="submit-btn" @tap="confirmPatientMsg">确定</button>
				</div>
			</div>
			<div id="selectItems" v-show="show3">
				<ul class="labTitle">
					<li @tap="backSingle"><i class="icon iconfont icon-fanhui"></i></li>
					<li><span @tap="selLab">{{defaultItemPrice}}({{invoiceType|isBilling}})<i class="icon iconfont icon-xialajiantou"></i></span></li>
				</ul>
				<header>
					<!--输入框-->
					<div class="inputBox">
						<!-- <i class="icon iconfont icon-sousuo search"></i> -->
						<input type="text" class="icon iconfont icon-sousuo search" :placeholder="placeholder" v-model="searchInput" @change="searchName"/>
						<span class="cancel btn-primary" @tap="search">搜索</span>
					</div>
				</header>
				<section>
					<!--列表导航-->
					<div class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					    <div class="mui-scroll">
					    	<!--解决IOS加载不出导航的兼容性问题-->
					        <a v-for="t,nIndex in tags" @tap='changeNav(t.hospitalProjectTagVos,nIndex)' 
					        	class="mui-control-item" :class="{'mui-active':navIndex==nIndex}">
					            {{t.projectTypeName}}
					        </a>
					    </div>
					</div>
					<!--列表详情-->				
					<div class="listContainer" :class="{minHeight:selectedProduct.size>0,paddingB280:selectedProduct.size>0}">
						<ul class="listLeft" v-if="subset">
							<li v-for="(ts,index) in tagsSon" @tap="changeTags(index)" 
								:class="{'active':tagIndex==index}">
								<span></span>{{ts.projectTagName}}</li>
						</ul>
						<ul class="listBox" :class="{maxWidth:!subset}">
							<li class="rel" v-for='p,index in pList' @tap='addProduct(p,index)'>
								<div class="selectList">
									<i class="iconfont icon-tubiaozhizuomoban left" 
										:class="{'icon-xuanzhong':p.show}"></i>
									<span>{{p.projectName}}</span>
									<span class="right">￥{{p.marketPrice}}</span>
								</div>
								<div class="cancelUse center" v-if="addUsedPro==p.projectId">
									{{usedTips}}
								</div>
							</li>
						</ul>
					</div>
				<!--底部弹出框-->
				</section>
				<div class="foot" v-show='ishasProduct'>
						<div class="listTitle center">
							您已勾选的检验项目
						</div>
						<ul class="listBox  selectProduct">
							<li class="listOrder" v-for="p in products">
								<span>{{p.obj.proName}}</span>
								<i class="iconfont icon-shanchu right" @tap="deleteProduct(p.id,p.obj.proName,p.obj.proPrice)"></i>
								<span class="right">￥{{p.obj.proPrice}}</span>
							</li>
						</ul>
						<div class="center selItemBtns">
							<span class="sumPrice">总金额：￥{{selectItemsSum}}</span>
							<button class="colorBtn btn-tag" @tap="confirmOrder">确定</button>
						</div>
					</div>
				</section>
			</div>
			<div id="successSubmit" v-show="show4">
				<ul>
					<li class="item1">
						<i class="icon iconfont icon-xuanzhong1"></i>
					</li>
					<li class="item2">提交成功</li>
					<li class="item3">提交成功后将自动返回首页</li>
				</ul>
			</div>
			<div id="labList" v-show="show6">
				<div class="labTitle">
					<li @tap="backLabItem"><i class="icon iconfont icon-fanhui"></i></li>
					<li>选择实验室</li>
				</div>
				<ul class="itemList">
					<li v-for="(itemP,index) in itemPriceList" @tap="selectLabItem(itemP)">
						{{itemP.name}}{{itemP.invoiceType|isBilling}}
					</li>
				</ul>
			</div>
		</div>
		
		<script src="../../../../js/mui.min.js"></script>
		<script src="../../../../js/vue.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../../../../js/mui.picker.min.js"></script>
		<script src="../../../../js/cmms.js?time=333"></script>
		<!--<script src="../../../js/vconsole.min.js"></script>-->
		<script type="text/javascript">
			mui.init()
		</script>
		<script type="text/javascript">
			new Vue({
				el:"#single",
				data(){
					return{
						token:'',
						show1:true,
						show2:false,
						show3:false,
						show4:false,
						show6:false,//实验室列表
						inputCode:'',//扫条形码
						selNum:'1',//标本个数
						selSample:'紫',//样本
						SampleData:[],//试管颜色选择集合
						specimenSamplingParams:[],
						tubeTypeArr:[],//试管类型
						tubeNumArr:[],
						barCodeArr:'',
						samplingTime:'',//采样时间
						imgSrcs:[],//选择图片地址
						imgIds:[],//附件id集合
						placeholder:'\ue604 请输入项目名称',
						//sing
						doctor:'',
						hospital:'',
						userId:'',
						subject:'添加患者',
						selectItem:'选择项目',
						//add
						patientName:'',//患者姓名
						sexMsg:'',
						dateBirth:'',//年龄
						patientPhone:'',//患者手机
						//selectItem
						searchInput:"",//检验项目input
						tags:[],//导航集合
						navId:'',//导航id
						tagsSon:[],//标签集合
						subset:true,//判断是否有左侧列
						tagIndex:0,//标签下标位置
						navIndex:0,
						selectItemsSum:0,//所选择的项目的总金额
						//productList:[],//产品列表
						pList:[],//产品列表
						addUsedPro:'',//添加常用
						selectedProduct:new Map(),//已选择的产品
	//					selectedProduct:[],
						ishasProduct:false,
						products:[],
						productsList:[],
						patientId:'',
						//isUsed:true,
						//usedTips:'已添加常用',
						isSearch:false,
						message:"",
						messageItem:[],
						ios:true,//解决IOS加载不出导航的兼容性问题
						isSubmit:true,
						remark:'',//备注
						ageUnit: '岁',
						haveKey:false,//添加项目搜索框有输入值为true，没有值为false
						itemPriceList:[],//项目价格体系
						defaultItemPrice:'',
						invoiceType:'',
						partnerHospitalLabId:'',//实验室id
					}
				},
				filters:{
					isBilling:function(val){
						switch(val){
							case 0:
								return '不可开票'
								break;
							case 1:
								return '可开票'
								break;
							break;
						}
					}
				},
				watch:{
					/*监听年龄只能为数字*/
					dateBirth:function(){
						this.dateBirth=this.dateBirth.replace(/[^\d]/g,'');
					},
					patientPhone:function(){
						this.patientPhone=this.patientPhone.replace(/[^\d]/g,'');
					},
					/*有值时haveKey为false*/
					message:function(){
						let _this=this;
						if(_this.message==''){
							_this.haveKey = false;
						}else{
							_this.haveKey = true;
						}
					},
				},
				created(){
					this.token=localStorage.getItem('sale_token');
					let url = location.href.split('?')[1].split('&');
					this.doctor=decodeURI(url[0].split('=')[1]);
					this.hospital=decodeURI(url[1].split('=')[1]);
					this.userId=url[2].split('=')[1];
					this.partnerHospitalId=(url[3].split('=')[1]).toString();
//					this.getNavTags();
				},
				mounted(){
					this.muiInit();
					// var vConsole = new VConsole();
//					this.imgSrcs = ['../../../img/bgcx2.png','../../../img/pre-btn.png'];
				},
				methods:{
					muiInit(){
						let _this=this;
						/*接口配置*/
		    			AT.muiAjax('/partner-sale/partnerSale/wxConfig','post',{url:location.href.split('#')[0]},function(res){
							wx.config({
								//debug: true,
								appId:res.appId,
								timestamp:res.timestamp,
								nonceStr:res.nonceStr,
								signature:res.signature,
								jsApiList:['scanQRCode','chooseImage','uploadImage','previewImage']
							});
						});
						_this.getLabList();
					},
					getHospitalTree(){
						let _this = this;
						_this.navIndex = 0;
						/*addItme获取导航和标签数据*/
						AT.muiAjax('/partner-sale/ludan/hospitalProject','post',{
							 projectName:_this.searchInput,
							 partnerHospitalLabId:_this.partnerHospitalLabId
						},function(realData){
//							console.log(realData);
							_this.pList = [];
							_this.tags=realData;
							if(realData[0].hospitalProjectTagVos[0].projectTagName!=''){
								_this.tagsSon = realData[0].hospitalProjectTagVos;
								_this.subset = true;
							}else{
								_this.subset = false;
							}
							let pList=realData[0].hospitalProjectTagVos[0].hospitalProjectVos;
							for(let i in pList){
								if(_this.selectedProduct.has(pList[i].projectId)){
									pList[i].show = true;
								}else{
									pList[i].show = false;
								}
							}
							_this.pList = pList;
							console.log('页面加载数据');
							console.log(_this.pList);
						});
					},
					getLabList(){
						let _this = this;
						AT.muiAjax('/partner-sale/ludan/hospitalPriceTypes','post',{
							 id:_this.partnerHospitalId
						},function(realData2){
							console.log(realData2)
							_this.itemPriceList = realData2;
							if(realData2.length>0){
								_this.defaultItemPrice = _this.itemPriceList[0].name;
								_this.invoiceType = _this.itemPriceList[0].invoiceType;
								_this.partnerHospitalLabId = _this.itemPriceList[0].id;
								if(_this.partnerHospitalLabId!=''){
									_this.getHospitalTree();
								}
							}
						});
					},
					/*上传图片*/
					uploadImg(){
						let _this=this;
						wx.chooseImage({
							count: 1, // 默认9
							sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
							sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
							success: function (res) {
								let localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
								_this.imgSrcs.push(localIds[0]);
								//alert(_this.imgSrcs);
								wx.uploadImage({
									localId: localIds[0], 
									isShowProgressTips: 1, 
									success: function (res) {
										var serverId = res.serverId; 
										_this.imgIds.push(serverId);
//										console.log(_this.imgIds);
//										console.log(serverId);
									}
								});
							}
						});
					},
					/*删除所选图片*/
					delwxIMG(index){
						let _this = this;
						_this.imgIds.splice(index,1);
						_this.imgSrcs.splice(index,1);
					},
					/*调用微信接口展示图片*/
					getImg(src){
						let _this=this;
						wx.previewImage({
							current: src, // 当前显示图片的http链接
							urls: _this.imgSrcs// 需要预览的图片http链接列表
						});
					},
					//扫描10-12位服务码
					scanBarcode(){
						let _this = this;
						wx.scanQRCode({
							needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
							scanType: ["barCode"], // 可以指定扫二维码还是一维码，默认二者都有
							success: function (res) {
								//console.(res);
								let resultStr = res.resultStr.split(',');
								let scanbarCode = resultStr[resultStr.length-1]; 
								_this.inputCode = scanbarCode; 	
								_this.barCodeArr=_this.inputCode;
							}
						});
					},
					/*条码添加*/
					addBarCode(){
						let _this = this;
						let reg=/^[A-Za-z0-9]+$/;
						
						if(!reg.test(_this.inputCode)){
							mui.alert('条码必须为字母、数字!');
						}else{
							_this.barCodeArr=_this.inputCode;
						}
					},
					/*删除条码*/
					delBarCode(){
						this.barCodeArr='';
						console.log(this.barCodeArr);
					},
					//选择实验室
					selLab(){
						let _this = this;
						console.log(_this.products)
						console.log(_this.selectedProduct.size);
						let itemArr = '';
						if(_this.selectedProduct.size>0){
//						if(_this.products.length>0){
							for(let i=0;i<_this.products.length;i++){
								console.log(_this.products[i].obj.proName);
								itemArr += _this.products[i].obj.proName+' ';
							}
							console.log(itemArr)
							var btnArray = ['取消', '确认'];
							mui.confirm(itemArr+'等项目将会移除？', '切换实验室', btnArray, function(e) {
			                    if (e.index == 1) {
			                        _this.show6 = true;
									_this.show3 = false;
									for(let i=0;i<_this.pList.length;i++){
										_this.pList[i].show = false;
									}
									_this.pList = [];
									_this.products = [];
									_this.partnerHospitalLabId = '';
									_this.selectItemsSum=0;
									_this.ishasProduct = false;
									_this.selectedProduct.clear();
									console.log(_this.partnerHospitalLabId)
			                    } else {
			                    	console.log('取消')
			                    }
			                })
						}else{
							_this.show6 = true;
							_this.show3 = false;
						}
					},
					//选中一项实验室
					selectLabItem(item){
						console.log(item);
						this.partnerHospitalLabId = item.id;
						console.log(this.partnerHospitalLabId);
						this.defaultItemPrice = item.name;
				    	this.invoiceType = item.invoiceType;
				    	this.show6 = false;
						this.show3 = true;
						this.pList = [];
						console.log(this.partnerHospitalLabId)
						this.getHospitalTree();
					},
					//返回选择项目界面
					backLabItem(){
						this.show6 = false;
						this.show3 = true;
					},
					//返回选录单界面
					backSingle(){
						this.show3 = false;
						this.show1 = true;
					},
					/*添加患者*/
					jumpToAdd(){
						this.show1=false;
						this.show2=true;
					},
					/*选择项目*/
					jumpSelectItem(){
						this.show1=false;
						this.show3=true;
					},
					/*样本*/
					selectSample(){
						let _this = this;
						var picker = new mui.PopPicker();
						AT.muiAjax('/common/common/selectDictDataListByDictCode','post',{
							typeCode:"container_type"
						},function(realData){
							console.log(realData);
							var str = [];
							for (var i = 0; i < realData.length; i++) {
							     var obj = {
							         value: realData[i].code,
							         text: realData[i].name
							     };
							     str.push(obj);
							}
							console.log(str);
							_this.SampleData = str;
							picker.setData(_this.SampleData);
							picker.show(function (selectItems) {
							    _this.selSample=selectItems[0].text;
							})
						});
					},
					//标本个数
					selectNum(){
						let _this = this;
						var picker = new mui.PopPicker();
						picker.setData([
							{value:'1',text:'1'},
							{value:'2',text:'2'},
							{value:'3',text:'3'},
							{value:'4',text:'4'},
							{value:'5',text:'5'},
							{value:'6',text:'6'},
							{value:'7',text:'7'},
							{value:'8',text:'8'},
							{value:'9',text:'9'},
							{value:'10',text:'10'},
							{value:'11',text:'11'},
							{value:'12',text:'12'},
							{value:'13',text:'13'},
							{value:'14',text:'14'},
							{value:'15',text:'15'},
							{value:'16',text:'16'},
							{value:'17',text:'17'},
							{value:'18',text:'18'},
							{value:'19',text:'19'},
							{value:'20',text:'20'}
						]);
						picker.show(function (selectItems) {
						    _this.selNum=selectItems[0].text;
						})
					},
					/*试管颜色添加*/
					addSample(){
						let _this = this;
//						console.log(_this.specimenSamplingParams);
						_this.tubeTypeArr=[];
						_this.tubeNumArr=[];
						_this.tubeTypeArr.push(_this.selSample);
						_this.tubeNumArr.push(_this.selNum);
						for (var i = 0; i < _this.tubeTypeArr.length; i++) {
						     var obj = {
						         samplingColor: _this.tubeTypeArr[i],
						         samplingNum: _this.tubeNumArr[i]
						     };
						     _this.specimenSamplingParams.push(obj);
						}
						console.log(_this.specimenSamplingParams);
					},
					/*删除样本*/
					delSample(index){
						console.log(index);
						this.specimenSamplingParams.splice(index,1);
						this.tubeNumArr.splice(index,1);
						this.tubeTypeArr.splice(index,1);
					},
					//确认受检人信息
					confirmPatientMsg(){
						let regPhone= /^1[3456789]\d{9}$/;
						let regAge = /^[0-9]*$/; 
						if(this.patientName==''){
							mui.alert('患者姓名不能为空');
							return false;
						}
						if(this.dateBirth==''){
							mui.alert('患者年龄不能为空');
							return false;
						}
						if(this.sexMsg==''){
							mui.alert('性别不能为空');
							return false;
						}
						if(this.patientPhone==''){
							mui.alert('患者电话号码不能为空');
							return false;
						}else if(!(regPhone.test(this.patientPhone))){
							mui.alert('患者电话号码有误，请检查');
							return false;
						}
						this.show1=true;
						this.show2=false;
						this.subject=this.patientName;
//						console.log(this.sexMsg);
					},
					backPatientMsg(){
						this.show1=true;
						this.show2=false;
					},
					//性别选择器
					selectSex(){
						let _this = this;
						var picker = new mui.PopPicker();
						picker.setData([{value:'1',text:'女'},{value:'2',text:'男'}]);
						picker.show(function (selectItems) {
						    _this.sexMsg=selectItems[0].text;
						    picker.dispose();
							picker = null;
						})
					},
					//监听姓名
					searchName(){
						if(this.searchInput==''){
							this.getHospitalTree();
						}
					},
					//采样时间选择器
					selectSamplingTime(){
						let _this = this;
						var options = {"type":"datetime","beginYear":1900,"endYear":2100};
						picker = new mui.DtPicker(options);
						picker.show(function(rs) {
							_this.samplingTime=rs.value;
							picker.dispose();
							picker = null;
						});
					},
					//年月天
					selectAgeUnit(){
						let _this = this;
						var picker = new mui.PopPicker();
						picker.setData([
							{value:'年',text:'岁'},
							{value:'个月',text:'个月'},
							{value:'天',text:'天'}
						]);
						picker.show(function (selectItems) {
						    _this.ageUnit=selectItems[0].text;
						})
					},
					//获取常用列表
					changeNavUsed(){
						let _this=this;
						AT.muiAjax('/partner-sale/partnerSale/doctorCommonProject','post',{
							 partnerHospitalId:_this.partnerHospitalId,
							 partnerHospitalUserId:_this.userId,
							 partnerHospitalLabId:_this.partnerHospitalLabId
						},function(realData){
							_this.subset=false;
							//console.log(realData);
							_this.tagsSon=realData;
							let pList=realData[0].projectList;
							for(let i in pList){
								if(_this.selectedProduct.has(pList[i].hospitalProjectId)){
									pList[i].show = true;
								}else{
									pList[i].show = false;
								}
							}
							_this.pList = pList;
						});
					},
					//项目选择部分
					//删除产品
					deleteProduct:function(id,proName,proPrice){
						let _this = this;
						_this.selectedProduct.delete(id);
						let arr = _this.pList;
						_this.pList =[];
						for(let i in arr){
							if(arr[i].hospitalProjectId==id){
								arr[i].show = arr[i].show?false:true;
							}
						}
						
						let obj = {
					        "proName":proName,
					        "proPrice":proPrice,
									"saleProjectVos":[
									]
					   	};
						 _this.pList = arr;
						if(_this.selectedProduct.size>=1){
		    				_this.ishasProduct = true;
		    				let products = [];
		    				_this.selectItemsSum=0;
		    				for(let [key,value] of _this.selectedProduct.entries()){
							  products.push({id:key,obj:value})
							  _this.selectItemsSum = _this.selectItemsSum+value.proPrice;
							}
		    				_this.products = products;
		    				console.log(products);
		    			}else{
		    				_this.ishasProduct = false;
		    			}
					},
					//添加产品
					addProduct:function(project,index){
						let _this = this;
						// _this.isSearch = false;
						let id = project.projectId;
						let arr = _this.pList;
						_this.pList =[];
						for(let i in arr){
							if(arr[i].projectId==id){
								arr[i].show = arr[i].show?false:true;
							}
						}
						_this.pList = arr;
						let obj = {
							"proName":project.projectName,
							"proPrice":project.marketPrice,
							"saleProjectVos":[
							]
						};
						if(_this.selectedProduct.has(id)){
		    				_this.selectedProduct.delete(id);
		    			}else{
								//判断是否为组套
								if(project.stackFlag){
									obj.saleProjectVos = project.subProjectDtoList;
								}
		    				_this.selectedProduct.set(id,obj);
		    			}
//		    			console.log(_this.selectedProduct);
		    			if(_this.selectedProduct.size>=1){
		    				_this.ishasProduct = true;
		    				let products = [];
//		    				console.log(_this.selectedProduct);
		    				_this.selectItemsSum=0;
		    				for(let [key,value] of _this.selectedProduct.entries()){
//		    					console.log(value);
							  	products.push({id:key,obj:value})
							  	//计算所选项目的总金额
		    					_this.selectItemsSum = _this.selectItemsSum+value.proPrice;
							}
		    				_this.products = products;
		    				
		    			}else{
		    				_this.ishasProduct = false;
		    			}
					},
					/*点击按钮搜索*/
					search:function(){
						let _this=this;
						this.getHospitalTree();
					},
					//标签切换
					changeTags:function(index){
						let _this = this;
						_this.tagIndex = index;
						_this.pList=_this.tagsSon[index].projectList;			
					},
					/*导航切换获取标签数据*/
					changeNav:function(tags,index){
						let _this=this;
						_this.tagIndex=0;
						_this.navIndex = index;
						_this.tagsSon = tags;
						if(tags[0].projectTagName!=''){
							_this.subset = true;
						}else{
							_this.subset = false;
						}
						_this.pList = [];
						let pList=tags[0].hospitalProjectVos;
						for(let i in pList){
							if(_this.selectedProduct.has(pList[i].projectId)){
								pList[i].show = true;
							}else{
								pList[i].show = false;
							}
						}
						_this.pList = pList;
					},
					//addItem确定
					//增加根据项目调用试管颜色
					confirmOrder:function(){
						let _this = this;
						let products = [];
						let item=[];
						_this.selectItem="";
						for(let [key,value] of _this.selectedProduct.entries()){
							products.push(key);
							item.push(value);
						}	
//						console.log(products);
//						console.log(item);
						//赋值给selectItem
						let proArr = [];
						for(let i=0;i<item.length;i++){
							proArr[i]=item[i].proName;
						}
						_this.selectItem=proArr.join(',');
						console.log(_this.selectItem);
						
						_this.productsList=products;
//						_this.specimenSamplingParams = [];
						/*根据项目选试管颜色*/
						let url = '/partner-sale/ludan/specimenSamplings';
						mui.ajax(AT.baseUrl + url, {
							data: {
								ids:products
							},
							dataType: 'json', //服务器返回json格式数据
							type: 'post', //HTTP请求类型
							//timeout: 10000, //超时时间设置为10秒；
							crossDomain: true,
							headers:{'Content-Type':'application/json','token':localStorage.getItem(localStorage.getItem("state")+"_sale_token")},
							success: (res)=>{
								console.log(res)
								let realData = res.data;
								if(res.code === 0){
									_this.show1=true;
									_this.show3=false;
									_this.specimenSamplingParams = realData;
								}else if(res.code === 1){
									mui.toast(res.msg);
									_this.show1=false;
									_this.show3=true;
								}else{
									if(res.msg!='用户未登录'){
										mui.toast('系统错误，请稍后再试！');
										_this.show3=true;
										_this.show5=false;
									}
								}
							},
							error: (xhr, type, errorThrown) =>{
								console.log('err'+type);
							}
						});
					},
					//清除输入框
					clearItemName(){
						this.message="";
					},
					//清除数据
					clearItem:function(){
						this.messageItem="";
						this.message="";
					},
					//提交订单
					submitOrder(){
						console.log(this.barCodeArr)
						let _this=this;
//						let reg=/^[a-zA-Z0-9]{10}$/;
						
						if(_this.subject=='添加患者'){
							mui.alert('请添加患者');
							return false;
						}
						if(_this.products.length==0){
							mui.alert('请选择检验项目');
							return false;
						}
						if(_this.barCodeArr==""){
							mui.alert('请输入或扫描服务码');
							return false;
						}
						if(_this.imgIds.length==0){
							mui.alert('请上传申请单');
							return false;
						}
						if(_this.samplingTime==""){
							mui.alert('请选择采样时间');
							return false;
						}
						_this.isSubmit = false;
						AT.muiAjax('/partner-sale/ludan/placeOrder','post',{
							 wxAttachmentIds:_this.imgIds,
							 projectIds:_this.productsList,
							 placeOrderPartnerHospitalParam: {
								// partnerHospitalId: _this.partnerHospitalId,
								partnerHospitalUserId: _this.userId
							 },
							 partnerHospitalLabId:_this.partnerHospitalLabId,
							 patient: {
								age: parseInt(_this.dateBirth),
								ageUnit:_this.ageUnit,
								mobile:_this.patientPhone,
								name:_this.patientName,
								sex: _this.sexMsg=='男'?2:1
							 },
							 remark:_this.remark,
							 samplingTime:_this.samplingTime,
							 serviceCode:_this.barCodeArr,
							 specimenSamplingParams:_this.specimenSamplingParams,
							 specimenSize:_this.selNum,
							 workflowCode:"03"
						},function(res){
							console.log(res);
							_this.show4=true;
							setTimeout(()=>{
								_this.show4 = false;
								location.reload();
							},1500)	
						});
					}
				}
			})
		</script>
	</body>

</html>